<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('qun',$QXARR))exit(noauth());
require_once ZEAI.'cache/config_up.php';
require_once ZEAI.'sub/zeai_up_func.php';
require_once ZEAI.'cache/config_vip.php';
require_once ZEAI.'cache/udata.php';
$urole = json_decode($_ZEAI['urole'],true);
sort($urole);
$sexARR = json_decode($_UDATA['sex'],true);
if ($submitok == "addupdate" || $submitok == "modupdate") {
	if(empty($title))json_exit(array('flag'=>0,'msg'=>'请输入【群名称】'));
	if(empty($title2))json_exit(array('flag'=>0,'msg'=>'请输入【副标题】'));
	if(str_len($content)>50000)json_exit(array('flag'=>0,'msg'=>'【群介绍】请小于50000字节'));
	$title   = trimm(dataIO($title,'in',200));
	$title2  = trimm(dataIO($title2,'in',200));
	$uid     = intval($uid);
	$click   = abs(intval($click));
	$content = dataIO($content,'in');
	$areaid = getareaSQL($areaid);
	$areaid = trimm(dataIO($areaid,'in'));
	$areatitle = dataIO($areatitle,'in');
	//男女最多各多少人$joinnum = '{"1":"2","2":"4"}';		
	$joinnum = array();	
	if (is_array($sexARR) && count($sexARR)>0){
		foreach($sexARR as $RV){
			$num = 'joinnum'.$RV['i'];
			$num = abs(intval($$num));
			$joinnum[$RV['i']] = $num;
		}
	}
	$joinnum = encode_json($joinnum);
	//入群费
	foreach($urole as $RV){
		$price1 = 'price1_'.$RV['g'];$price1 = abs(floatval($$price1));
		$price2 = 'price2_'.$RV['g'];$price2 = abs(floatval($$price2));
		$json_price['1_'.$RV['g']] = $price1;
		$json_price['2_'.$RV['g']] = $price2;
	}
	$price = encode_json($json_price);
	$tag = str_replace("<br><br>","",dataIO($tag,'in',200));
	$addloveb  = abs(intval($addloveb));
	$addhhnum  = abs(intval($addhhnum));
	$addqxnum  = abs(intval($addqxnum));
	$chatqx  = intval($chatqx);
	$flag= intval($flag);
	$bz      = dataIO($bz,'in');
	$addtime = (empty($addtime))?ADDTIME:strtotime($addtime);
	/**tj**/
	$age = $age1.','.$age2;$tj['age'] = $age;
	if(!empty($sex))$tj['sex'] = implode(",",$sex);
	if(!empty($love))$tj['love'] = implode(",",$love);
	if(!empty($edu))$tj['edu'] = implode(",",$edu);
	if(!empty($pay))$tj['pay'] = implode(",",$pay);
	if(!empty($house))$tj['house'] = implode(",",$house);
	if(!empty($car))$tj['car'] = implode(",",$car);
	$tj_areaid = getareaSQL($tj_areaid);
	$tj_area2id = getareaSQL($tj_area2id);
	$tj_areaid = dataIO($tj_areaid,'in');$tj['areaid']=trimm($tj_areaid);
	$tj_area2id = dataIO($tj_area2id,'in');$tj['area2id']=trimm($tj_area2id);
	$tj_areatitle = dataIO($tj_areatitle,'in');$tj['areatitle']=$tj_areatitle;
	$tj_area2title = dataIO($tj_area2title,'in');$tj['area2title']=$tj_area2title;
	if(!empty($tj_grade))$tj_grade = implode(",",$tj_grade);$tj['grade']=$tj_grade;
	if(!empty($tj_before))$tj_before = implode(",",$tj_before);$tj['before']=$tj_before;
	if(!empty($tj_before_px))$tj_before_px= dataIO($tj_before_px,'in',500);$tj['before_px']=$tj_before_px;
	$tj_before_bfb_num=intval($tj_before_bfb_num);
	$tj_before_bfb_num=($tj_before_bfb_num>100)?100:$tj_before_bfb_num;$tj['before_bfb_num']=$tj_before_bfb_num;
	$tj = encode_json($tj);
	if($submitok == "addupdate"){
		if(!empty($path_s)){
			adm_pic_reTmpDir_send($path_s,'qun');
			adm_pic_reTmpDir_send(smb($path_s,'b'),'qun');
			$path_s = str_replace('tmp','qun',$path_s);
		}
		if(!empty($bn_s)){
			adm_pic_reTmpDir_send($bn_s,'qun');
			adm_pic_reTmpDir_send(smb($bn_s,'b'),'qun');
			$bn_s = str_replace('tmp','qun',$bn_s);
		}
		$addtime=ADDTIME;
		$px=ADDTIME;
		$db->query("INSERT INTO ".__TBL_QUN__."  (title,title2,uid,content,path_s,bn_s,areaid,areatitle,joinnum,price,tag,flag,addtime,px,chatqx,addloveb,addhhnum,addqxnum,tj,bz,click) VALUES ('$title','$title2','$uid','$content','$path_s','$bn_s','$areaid','$areatitle','$joinnum','$price','$tag','$flag','$addtime','$px','$chatqx','$addloveb','$addhhnum','$addqxnum','$tj','$bz',$click)");	
		$id = intval($db->insert_id());
		AddLog('新增【单身群】ID:'.$id.'，群名:'.$title);
	}elseif($submitok=='modupdate'){
		if(!ifint($id))json_exit(array('flag'=>0,'msg'=>'ID跑路了，请联系开发者【择。爱 www。a9a。cn金。媒】官方客服'));
		$row = $db->ROW(__TBL_QUN__,"path_s,bn_s"," id=".$id,"num");
		if (!$row)json_exit(array('flag'=>0,'msg'=>'zeai_error_db_fid'.$id));
		$data_path_s= $row[0];$data_bn_s= $row[1];
		$SQL="";
		//
		$path_s = tmp_piclist_modupdate($path_s,$data_path_s,'qun','alone');
		$SQL .= ",path_s='$path_s'";
		$bn_s = tmp_piclist_modupdate($bn_s,$data_bn_s,'qun','alone');
		$SQL .= ",bn_s='$bn_s'";
		//
		$db->query("UPDATE ".__TBL_QUN__." SET title='$title',title2='$title2',uid='$uid',content='$content',areaid='$areaid',areatitle='$areatitle',joinnum='$joinnum',price='$price',tag='$tag',flag='$flag',chatqx='$chatqx',addloveb='$addloveb',addhhnum='$addhhnum',addqxnum='$addqxnum',tj='$tj',bz='$bz',click='$click',addtime='$addtime'".$SQL." WHERE id=".$id);
		AddLog('修改【单身群】ID:'.$id.'，群名:'.$title);
	}
	if(ifint($uid)){
		$row = $db->ROW(__TBL_QUN_U__,"id","qid=".$id." AND uid=".$uid);
		if (!$row)$db->query("INSERT INTO ".__TBL_QUN_U__."(qid,uid,addtime) VALUES ($id,$uid,".ADDTIME.")");
	}
	json_exit(array('flag'=>1,'msg'=>'操作成功'));
}elseif($submitok=='ajax_pic_path_s_up'){
	if (ifpostpic($file['tmp_name'])){
		$dbname = setphotodbname('tmp',$file['tmp_name'],$session_uid.'qun_');
		if (!up_send($file,$dbname,0,$_UP['upMsize'],'150*150'))json_exit(array('flag'=>0,'msg'=>'图片写入失败'));
		$dbname=setpath_s($dbname);
		AddLog('【单身群】上传图标->url:'.$dbname);
		json_exit(array('flag'=>1,'msg'=>'上传成功','dbname'=>$dbname));
	}else{
		json_exit(array('flag'=>0,'msg'=>'zeai_tmp_name_error'));
	}
}elseif($submitok=='ajax_pic_bn_s_up'){
	if (ifpostpic($file['tmp_name'])){
		$dbname = setphotodbname('tmp',$file['tmp_name'],$session_uid.'qun_');
		if (!up_send($file,$dbname,0,$_UP['upMsize'],'720*720'))json_exit(array('flag'=>0,'msg'=>'图片写入失败'));
		$dbname=setpath_s($dbname);
		AddLog('【单身群】上传Banner图->url:'.$dbname);
		json_exit(array('flag'=>1,'msg'=>'上传成功','dbname'=>$dbname));
	}else{
		json_exit(array('flag'=>0,'msg'=>'zeai_tmp_name_error'));
	}
}elseif($submitok=='ajax_del'){
	if (!ifint($id))json_exit(array('flag'=>0,'msg'=>'单身群不存在或已被删除'));
	$rt = $db->query("SELECT path_s,bn_s,title FROM ".__TBL_QUN__." WHERE id=".$id);
	$total = $db->num_rows($rt);
	if ($total > 0 ) {
		for($i=1;$i<=$total;$i++) {
			$row = $db->fetch_array($rt,'name');
			if(!$row) break;
			$path_s = $row['path_s'];$bn_s = $row['bn_s'];$title = $row['title'];
			if(!empty($path_s)){$B = smb($path_s,'b');}
			if(!empty($bn_s)){$B2 = smb($bn_s,'b');}
			@up_send_admindel($path_s.'|'.$B.'|'.$bn_s.'|'.$B2);
		}
		$db->query("DELETE FROM ".__TBL_QUN__." WHERE id=".$id);
		$db->query("DELETE FROM ".__TBL_QUN_U__." WHERE qid=".$id);
		$db->query("DELETE FROM ".__TBL_TREND__." WHERE kind=2 AND qid=".$id);
		$db->query("DELETE FROM ".__TBL_TREND_BBS__." WHERE kind=2 AND qid=".$id);
		AddLog('删除【单身群】->ID:'.$id.'，群名:'.$title);
	}
	json_exit(array('flag'=>1,'msg'=>'删除成功'));
}elseif($submitok=='ajax_flag'){//1报名中，2进行中，3结束
	if (!ifint($id))callmsg("ID跑路了","-1");
	$row = $db->ROW(__TBL_QUN__,"flag","id=".$id,"num");
	if(!$row){
		alert_adm("您要操作的信息不存在","-1");
	}else{
		$flag = $row[0];
		$SQL = "";
		switch($flag){
			case"-1":$SQL="flag=1";break;
			case"0":$SQL="flag=1";break;
			case"1":$SQL="flag=-1";break;
		}
		$db->query("UPDATE ".__TBL_QUN__." SET ".$SQL." WHERE id=".$id);
		AddLog('【单身群】状态修改->id:'.$id);
		json_exit(array('flag'=>1,'msg'=>'设置成功'));
	}
}elseif($submitok=='ding'){
	if (!ifint($id))alert_adm("forbidden","-1");
	$db->query("UPDATE ".__TBL_QUN__." SET px=".ADDTIME." WHERE id=".$id);
	AddLog('【单身群】置顶->id:'.$id);
	header("Location: ".SELF);
}
$SQL = "";
$Skey = trimm($Skey);
if (ifint($Skey)){
	$SQL = " WHERE id=$Skey ";
}elseif(!empty($Skey)){
	$SQL = " WHERE title LIKE '%".$Skey."%' ";
}
$rt = $db->query("SELECT id,title,addtime,path_s,flag,click,uid,joinnum,price,chatqx,tj FROM ".__TBL_QUN__.$SQL." ORDER BY px DESC,id DESC LIMIT ".$_ADM['admLimit']);
$total = $db->num_rows($rt);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="js/Sortable1.6.1.js"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<script src="<?php echo HOST;?>/cache/udata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/areadata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/res/select4.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
td.tdLbgHUI{background-color:#eee}
.tips,.tips2{font-size:12px}
.ifadmlist{padding:0 10px;border:#eee 1px solid;background-color:#F5F6FA;margin-bottom:10px;text-align:center;line-height:150%;}
.ifadmlist li{width:150px;text-align:left;height:100px;text-align:center;display:inline-block}
.ifadmlist li img{margin-right:6px;display:block;margin:15px auto 5px auto}
.ifadmlist .brr{margin:15px 0;padding-top:15px;border-top:#eee 1px solid;line-height:200%;color:#999}
.listdatabox{padding:10px 0}
.listdatabox li{display:inline-block;padding:1px 5px;border:#ddd 1px solid;margin:3px;border-radius:3px;color:#888}
.table0 td{font-size:14px;padding:5px 0;text-align:left}
.table0 td input[type="text"]{margin:0 5px}
.listadd{min-width:900px;width:98%;margin:10px 20px 20px 20px}
.listadd td{text-align:center}
.box{min-width:1200px;padding:0}
</style>
<!-- editor -->
<link rel="stylesheet" href="editor/themes/default/default.css" />
<script charset="utf-8" src="editor/kindeditor.js?1"></script>
<script charset="utf-8" src="editor/lang/zh_CN.js?1"></script>
<script>
var editor;
KindEditor.ready(function(K){
  editor=K.create('textarea[name="content"]',{
	resizeType :1,
	cssData:'body {font-family: "微软雅黑"; font-size: 14px}',
	minWidth : 400,
	allowPreviewEmoticons : true,
	allowImageUpload : true,
	afterBlur:function(){this.sync();},
	items : [
		'fontsize', '|', 'forecolor', 'hilitecolor', 'bold','removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright','|',
		'selectall', '|','image', '|','plainpaste','wordpaste','hr', 'link', 'unlink','baidumap', '|','clearhtml','source', '|','preview','fullscreen']
  });
});
var up2='<?php echo $_ZEAI['up2'];?>/',upMaxMB=<?php echo $_UP['upMaxMB']; ?>;
</script>
<!--editor end -->
</head>
<body>
<div class="box">
	<div class="boxL">
    <a href="qun.php"<?php echo (empty($submitok) || $submitok=='add' || $submitok=='mod')?' class="ed"':'';?>>单身群列表<b><?php echo $total;?></b></a>
    <a href="qun_u.php">单身群成员</a>
    <a href="qun_trend.php">单身群话题</a>
    <a href="qun_bbs.php">单身群评论</a>
    </div>
	<div class="boxR">
		<?php
        if ($submitok == 'add' || $submitok == 'mod'){
            if ($submitok == 'add'){
                $tj_before_px = 'photo,rz_mob,rz_identity,rz_photo,bfb';
				$tj['before_px'] = $tj_before_px;
				$tj_before_bfb_num = 60;$tj['before_bfb_num']=$tj_before_bfb_num;
                $ifadmlist=array();
				$flag=1;
				$addloveb=0;
				$addhhnum=0;
				$addqxnum=0;
				$addtime = ADDTIME;
            }else{
                if(!ifint($id))alert_adm("ID去向不明","-1");
                $row = $db->ROW(__TBL_QUN__,"*","id=".$id,"name");
                if ($row){
                    $id           = $row['id'];
                    $title        = dataIO($row['title'],'out');
                    $title2       = dataIO($row['title2'],'out');
                    $content      = dataIO($row['content'],'out');
                    $uid = intval($row['uid']);
                    $path_s    = $row['path_s'];
                    $bn_s      = $row['bn_s'];
                    $areaid    = dataIO($row['areaid'],'out');
                    $areatitle = dataIO($row['areatitle'],'out');
                    $joinnum = dataIO($row['joinnum'],'out');
                    $price   = dataIO($row['price'],'out');
                    $tag     = dataIO($row['tag'],'out');
                    $flag    = intval($row['flag']);
					$click   = intval($row['click']);
                    $addtime = $row['addtime'];
                    $chatqx   = dataIO($row['chatqx'],'out');
                    $addloveb = intval($row['addloveb']);
                    $addhhnum = intval($row['addhhnum']);
                    $addqxnum = intval($row['addqxnum']);
					$tj = json_decode(dataIO($row['tj'],'out'),true);
                    $bz = dataIO($row['bz'],'out');
                }
            }?>
            <form id="ZEAI_FORM">
            <table class="table size2 W98_" style="margin:0 auto">
            <tr><td height="50" colspan="4" class="S18 B"><?php if($submitok == 'add')echo '创建';if($submitok == 'mod')echo '修改';?>群</td></tr>
            <tr><td class="tdL"><font class="Cf00">*</font> 群名称</td><td class="tdR"><input name="title" id="title" type="text" class="input size2 W200" value="<?php echo $title;?>" maxlength="200"   autocomplete="off" /></td>
              <td class="tdL">群主UID</td>
              <td class="tdR"><input name="uid" id="uid" type="text" class="input size2 W120" value="<?php echo $uid; ?>" size="10" maxlength="10"><span class="tips">前台单身用户UID，可以在前台删贴踢人等</span></td>
            </tr>
            <tr><td class="tdL"><font class="Cf00">*</font> 副标题</td><td colspan="3" class="tdR"><input name="title2" id="title2" type="text" class="input size2 W500" value="<?php echo $title2;?>" maxlength="200" autocomplete="off" /><span class="tips">精简说明，比如宗旨、口号、亮点、特色等</span></td></tr>
            <tr>
              <td class="tdL">群状态</td><td class="tdR">
                <input type="radio" name="flag" value="1" id="parent1" class="radioskin"<?php echo ($flag == 1)?' checked':'';?>><label for="parent1" class="radioskin-label"><i class="i1"></i><b class="W100">正常</b></label>
                <input type="radio" name="flag" value="2" id="parent2" class="radioskin"<?php echo ($flag == 2)?' checked':'';?>><label for="parent2" class="radioskin-label"><i class="i1"></i><b class="W100">禁止加入</b></label>

                <input type="radio" name="flag" value="-1" id="parent_1" class="radioskin"<?php echo ($flag == -1)?' checked':'';?>><label for="parent_1" class="radioskin-label"><i class="i1"></i><b class="W100">锁定・隐藏</b></label>
                <input type="radio" name="flag" value="0" id="parent_0" class="radioskin"<?php echo ($flag == 0)?' checked':'';?>><label for="parent_0" class="radioskin-label"><i class="i1"></i><b class="W100">未审</b></label>
              </td>
              <td class="tdL">发贴权限</td>
              <td class="tdR">
                <input type="radio" name="chatqx" value="0" id="chatqx0" class="radioskin"<?php echo ($chatqx == 0)?' checked':'';?>><label for="chatqx0" class="radioskin-label"><i class="i1"></i><b class="W80">全体成员</b></label>
                <input type="radio" name="chatqx" value="1" id="chatqx1" class="radioskin"<?php echo ($chatqx == 1)?' checked':'';?>><label for="chatqx1" class="radioskin-label"><i class="i1"></i><b class="W80">只有群主</b></label>
                <input type="radio" name="chatqx" value="2" id="chatqx2" class="radioskin"<?php echo ($chatqx == 2)?' checked':'';?>><label for="chatqx2" class="radioskin-label"><i class="i1"></i><b class="W80">全体禁言</b></label>
              </td>
            </tr>
            <tr><td class="tdL"><font class="Cf00">*</font> 群图标</td><td class="tdR C8d">
                <div class="picli100" id="picli_path">
                  <li class="add" id="path_add"></li>
                  <?php if(!empty($path_s)){
                        echo '<li><img src="'.$_ZEAI['up2'].'/'.$path_s.'"><i></i></li><br><span class="tips" >先删除后更换</span>';
                    }?>
                </div>
              <?php if(empty($path_s)){?><br><span class="tips" style="display:inline-block;line-height:150%">群LOGO图标，尺寸150×150像素<br>格式gif/jpg/png，推荐65%品质jpg</span><?php }?>
            </td>
              <td class="tdL"><font class="Cf00">*</font> 顶部海报</td>
              <td class="tdR C8d">
                <div class="picli100" id="picli_path2">
                  <li class="add" id="path_add2"></li>
                  <?php if(!empty($bn_s)){
                        echo '<li><img src="'.$_ZEAI['up2'].'/'.$bn_s.'"><i></i></li><br><span class="tips" >先删除后更换</span>';
                    }?>
                </div>
              <?php if(empty($bn_s)){?><br><span class="tips" style="display:inline-block;line-height:150%">群主页顶部Banner图片，尺寸720×700像素<br>格式gif/jpg/png，推荐65%品质jpg</span><?php }?>
              </td>
            </tr>
            <tr>
            <td class="tdL">地　区</td>
            <td colspan="3" class="tdR">
            <?php $areaid = explode(',',$areaid);$a1 = $areaid[0];$a2 = $areaid[1];$a3 = $areaid[2];$a4 = $areaid[3];?>
            <script>LevelMenu4('a1|a2|a3|a4||<?php echo $a1; ?>|<?php echo $a2; ?>|<?php echo $a3; ?>|<?php echo $a4; ?>|areaid|areatitle|<?php echo $areatitle;?>',' class="SW SW_area"');</script>
            </td>
            </tr>
            <tr>
            <td class="tdL"><font class="Cf00">*</font> 人数限定</td>
            <td colspan="3" class="tdR">
                <?php
                $joinnum = json_decode($joinnum,true);
                if (is_array($sexARR) && count($sexARR)>0){
					foreach($sexARR as $V){
						echo '　'.$V['v'];?> <input name="joinnum<?php echo $V['i'];?>" type="text" class="W80" maxlength="8" value="<?php echo intval($joinnum[$V['i']]);?>"> 人　　<?php
					}
                }else{
                    echo "<div class='nodatatipsS'>暂无性别</div>";
                }?><span class="tips">群最多容纳人数，超过将不能加入，填0不限人数</span>
            </td>
            </tr>
            <tr>
            <td class="tdL">入群费</td>
            <td class="tdR">
                <?php
                $price = json_decode($price,true);
                if (is_array($urole) && count($urole)>0){?>
                <table class="table0" style="min-width:430px;margin:0">
                    <?php
                    foreach($urole as $RV){
						if($RV['f']==0)continue;
                        $grade = $RV['g'];?>
                        <tr>
                        <td align="left">　<font style="vertical-align:middle"><?php echo $RV['t'];?></font> <i class="ico Caaa S18" style="margin:0 5px;vertical-align:middle">&#xe62d;</i></td>
                        <td width="300" align="left">
                         <?php echo uicon_grade_all($grade,1,1); ?>男 <input name="price1_<?php echo $grade;?>" id="price1_<?php echo $grade;?>" type="text" class="size2 FVerdana" maxlength="6" value="<?php echo floatval($price['1_'.$grade]);?>" style="width:60px"> 元　
                         <?php echo uicon_grade_all($grade,1,2); ?>女 <input name="price2_<?php echo $grade;?>" id="price2_<?php echo $grade;?>" type="text" class="size2 FVerdana" maxlength="6" value="<?php echo floatval($price['2_'.$grade]);?>" style="width:60px"> 元
                        </td>
                        </tr>
                        <?php
                    }?>
                </table>
                <?php }else{
                    echo "<div class='nodatatipsS'>暂无用户组<br><br><a class='btn size1' href='urole.php'>新增用户组</a></div>";
                }
                ?>
                <span class="tips">加入群收费，填0免费入群</span>
            </td>
            <td class="tdL">标　签</td>
            <td class="tdR"><textarea name="tag" style="padding:10px" cols="30" rows="7" class="W100 S14" id="tag" placeholder="如：&#13;&#13;90后&#13;再婚&#13;高收入&#13;白领&#13;离异&#13;高富帅"><?php echo str_replace("<br>","\r",dataIO($tag,'out'));?></textarea><div class="tips2">贴标签，<b>一行一个</b>，不能有空行，请控制在3个左右，推荐3个显示效果最佳</div></td>
            </tr>
            <tr>
            <td class="tdL">入群福利</td>
            <td colspan="3" class="tdR">
            奖励<?php echo $_ZEAI['loveB'];?> <input name="addloveb" type="text" class="W80" maxlength="8" value="<?php echo $addloveb ;?>"> 个　　
            赠送互换微信手机 <input name="addhhnum" type="text" class="W80" maxlength="8" value="<?php echo $addhhnum ;?>"> 次　　
            赠送人工牵线 <input name="addqxnum" type="text" class="W80" maxlength="8" value="<?php echo $addqxnum ;?>"> 次
            </td>
            </tr>
            <tr><td class="tdL">群介绍</td><td colspan="3" class="tdR"><img src="images/!.png" width="14" height="14" valign="middle"> <span style="font-size:12px;vertical-align:middle;color:#999">如果从公众号编辑器或外部网页或Word里拷入内容请先过虑垃圾代码，请点击下方</span> <img src="images/cclear.png" class="picmiddle"> <span class="tips picmiddle">图标，然后插入文字内容</span><textarea name="content" id="content" class="textarea_k" style="width:100%;height:120px" ><?php echo $content;?></textarea></td></tr>
            <tr><td class="tdL">创建时间</td><td class="tdR">
            <input name="addtime" id="addtime" type="text" class="input size2 W200" maxlength="50" value="<?php echo YmdHis($addtime);?>" />　　
            <span class="FR">人气 <input name="click" id="click" type="text" class="input size2 W80" maxlength="8" value="<?php echo intval($click);?>" /></span>
            </td>
              <td class="tdL">备　　注</td>
              <td class="tdR"><textarea name="bz" rows="3" class="W100_" placeholder="备注(500字节内，没有请留空)，不对外展示，内部备注"><?php echo $bz;?></textarea></td>
            </tr>
            <?php 
			$sex=$tj['sex'];
			$age=$tj['age'];$ageARR=explode(',',$age);$age1=$ageARR[0];$age2=$ageARR[1];
			$love=$tj['love'];
			$edu=$tj['edu'];
			$pay=$tj['pay'];
			$house=$tj['house'];
			$car=$tj['car'];
			$tj_areaid = explode(',',$tj['areaid']);$m1 = $tj_areaid[0];$m2 = $tj_areaid[1];$m3 = $tj_areaid[2];$m4 = $tj_areaid[3];
			$tj_area2id = explode(',',$tj['area2id']);$h1 = $tj_area2id[0];$h2 = $tj_area2id[1];$h3 = $tj_area2id[2];$h4 = $tj_area2id[3];
			$tj_areatitle = $tj['areatitle'];
			$tj_area2title = $tj['area2title'];
			?>
            <tr><td height="50" colspan="4" class="S18 B">入群条件<h6><font class="Cf00">*如果项目都不打勾，代表不限制</font></h6></td></tr>
            <tr><td class="tdL">性　　别</td><td class="tdR">
            <script>zeai_cn__CreateFormItem('checkbox','sex','<?php echo $sex;?>','<?php echo $class;?>');</script>
            </td>
              <td class="tdL">年　　龄</td>
              <td class="tdR"><input autocomplete="off"  name="age1" id="age1" type="text" class="size2 W80 FVerdana" maxlength="2" value="<?php echo $age1;?>">　-　<input autocomplete="off" name="age2" id="age2" type="text" class="size2 W80 FVerdana" maxlength="2" value="<?php echo $age2;?>"> 岁</td>
            </tr>
            <tr><td class="tdL">婚　　况</td><td colspan="3" class="tdR"><script>zeai_cn__CreateFormItem('checkbox','love','<?php echo $love;?>','<?php echo $class;?>');</script></td></tr>
            <tr><td class="tdL">学　　历</td><td colspan="3" class="tdR"><script>zeai_cn__CreateFormItem('checkbox','edu','<?php echo $edu;?>','<?php echo $class;?>');</script></td></tr>
            <tr><td class="tdL">收　　入</td><td colspan="3" class="tdR"><script>zeai_cn__CreateFormItem('checkbox','pay','<?php echo $pay;?>','<?php echo $class;?>');</script></td></tr>
            <tr><td class="tdL">房　　子</td><td colspan="3" class="tdR"><script>zeai_cn__CreateFormItem('checkbox','house','<?php echo $house;?>','<?php echo $class;?>');</script></td></tr>
            <tr><td class="tdL">车　　子</td><td colspan="3" class="tdR"><script>zeai_cn__CreateFormItem('checkbox','car','<?php echo $car;?>','<?php echo $class;?>');</script></td></tr>
            
            <tr><td class="tdL">地　　区</td><td colspan="3" class="tdR">
            <script>LevelMenu4('m1|m2|m3|m4||<?php echo $m1; ?>|<?php echo $m2; ?>|<?php echo $m3; ?>|<?php echo $m4; ?>|tj_areaid|tj_areatitle|<?php echo $tj_areatitle;?>',' class="SW SW_area"');</script></td></tr>
            <tr><td class="tdL">户　　籍</td><td colspan="3" class="tdR">
            <script>LevelMenu4('h1|h2|h3|h4||<?php echo $h1; ?>|<?php echo $h2; ?>|<?php echo $h3; ?>|<?php echo $h4; ?>|tj_area2id|tj_area2title|<?php echo $tj_area2title;?>',' class="SW SW_area"','hj');</script></td></tr>
            
			<tr><td class="tdL">用&nbsp;&nbsp;户&nbsp;&nbsp;组</td><td colspan="3" class="tdR">
			<?php if (is_array($urole) && count($urole)>0){
			$tj_grade = (empty($tj['grade']))?array():explode(',',$tj['grade']);
            foreach($urole as $RV){if($RV['f']==0)continue;$grade = $RV['g'];?>
            	<input type="checkbox" name="tj_grade[]" id="tj_grade_<?php echo $grade;?>" class="checkskin" value="<?php echo $grade;?>"<?php echo (in_array($grade,$tj_grade))?' checked':'';?>><label for="tj_grade_<?php echo $grade;?>" class="checkskin-label"><i class="i1"></i><b class="W150"><?php echo uicon_grade_all($grade); ?> <font style="vertical-align:middle"><?php echo $RV['t'];?></font></b></label>
			<?php }
			  }else{echo "<div class='nodatatipsS'>暂无用户组<br><br><a class='btn size1' href='urole.php'>新增用户组</a></div>";}?>
              <div><span class="tips2">只有勾选的用户等级用户才能入群，等级不够会自动跳转VIP升级页面</span></div>
            
            </td></tr>
            <tr><td class="tdL">其它条件</td><td colspan="3" class="tdR">
             <style>
                .stepbox .stepli3{margin-top:5px}
                .stepbox .stepli3 li{height:32px;padding:5px 10px;float:left;margin:5px;border:#ddd 1px solid;cursor:move;background-color:#f8f8f8;border-radius:3px}
                .FVerdana{background-color:#fff}
                </style>
                <dd class="stepbox" id="stepbox3">
                    <div class="stepli3">
                        <?php
                        $tj_beforeARR    = explode(',',$tj['before']);
                        $tj_before_pxARR = explode(',',$tj['before_px']);
                        if (count($tj_before_pxARR) >= 1 && is_array($tj_before_pxARR)){
                            foreach ($tj_before_pxARR as $k=>$V) {?>
                                <li><input type="checkbox" name="tj_before[]" id="tj_before_<?php echo $V;?>" class="checkskin bmtj_li" value="<?php echo $V;?>"<?php echo (in_array($V,$tj_beforeARR))?' checked':'';?>><label for="tj_before_<?php echo $V;?>" class="checkskin-label"><i class="i1"></i>
                                <b class="<?php ($V == 'bfb')?'W200':'W100';?>"><?php echo chatContact_data_title($V);?>
                                <?php if ($V == 'bfb'){?> <input name="tj_before_bfb_num" type="text" class="W50 FVerdana" maxlength="3" value="<?php echo intval($tj['before_bfb_num']);?>"> %<?php }?>
                                </b></label></li>
                                <?php
                            }
                        }
                        ?>
                    </div>
                    <div class="clear"></div>
                </dd>
                <font class="S12 C999">可以按住不放拖动项目调整前后顺序，系统检查规则(从左到右)，选中请打勾，选中将进行验证和检查，不符合将不能报名（自动弹出引导页面完善），如全不选将忽略检查</font>
                <input name="tj_before_px" id="tj_before_px" type="hidden" value="<?php echo $tj_before_px;?>">
</td></tr>
            </table>
            <input name="submitok" type="hidden" value="<?php echo $submitok.'update';?>" />
            <input name="path_s" id="path_s" type="hidden" value="" />
            <input name="bn_s" id="bn_s" type="hidden" value="" />
            <?php if ($submitok == 'mod'){?><input name="id" type="hidden" value="<?php echo $id;?>" /><?php }?>
            </form>
        <?php }else{ ?>
        
      <!-- LIST -->
            <div class="topsearch">
            	<button type="button" class="btn size2" onClick="zeai.openurl('qun.php?submitok=add')"><i class="ico">&#xe622;</i> 创建单身群</button>
                <div class="rbox">
                <form name="ZEAI_CN__form1" method="get" action="<?php echo SELF; ?>">
                    <input name="Skey" type="text" id="Skey" maxlength="25" class="input size2 W200" placeholder="输入群ID/名称" value="<?php echo $Skey; ?>">
                    <input type="hidden" name="p" value="<?php echo $p;?>" />
                    <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
                </form>
                </div>
            </div>            
            <?php
            if ($total <= 0 ){
                echo "<div class='nodataico'><i></i>暂无内容<br><a class='aQINGed' href='qun.php?submitok=add'>创建单身群</a></div>";
            } else {
                $page_skin=2;$pagemode=3;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';?>
                <form id="www_zeai_cn_FORM" method="get" action="<?php echo SELF; ?>">
                    <table class="tablelist" >
                    <tr>
                    <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
                    <th width="35">ID</th>
                    <th width="30" align="center">置顶</th>
                    <th width="60" align="center">群图标</th>
                    <th width="170" align="left">群名称/群主</th>
                    <th width="50" align="center">扫码浏览</th>
                    <th align="center">&nbsp;</th>
                    <th width="45" align="center">群成员</th>
                    <th width="45" align="center">群话题</th>
                    <th width="45" align="center">评论</th>
                    <th width="22" align="center">&nbsp;</th>
                    <th width="170">　入群费用</th>
                    <th width="70" align="center">创建时间</th>
                    <th width="60" align="center">状态/发言权限</th>
                    <th width="60" align="center">操作</th>
                    <th width="15" align="center">&nbsp;</th>
                    </tr>
                    <?php
                    for($i=1;$i<=$pagesize;$i++) {
                        $rows = $db->fetch_array($rt,'name');
                        if(!$rows) break;
                        $id = $rows['id'];
						$qid = $id;
                        $title = dataIO($rows['title'],'out');
                        $title = str_replace($Skey,"<font color=red><b>".$Skey."</b></font>",$title);
                        $path_s  = $rows['path_s'];
                   		$flag    = intval($rows['flag']);
                        $click = $rows['click'];
						$uid = intval($rows['uid']);
						$joinnum = dataIO($rows['joinnum'],'out');
						$price   = dataIO($rows['price'],'out');
						$addtime = $rows['addtime'];
						$chatqx   = dataIO($rows['chatqx'],'out');
						$tj = json_decode(dataIO($rows['tj'],'out'),true);
                        if(!empty($path_s)){
                            $path_s_url = $_ZEAI['up2'].'/'.$path_s;
                            $path_s_str = '<img src="'.$path_s_url.'">';
                        }else{
                            $path_s_url = '';
                            $path_s_str = '';
                        }
                        $path_s_url = (!empty($path_s))?$_ZEAI['up2'].'/'.$path_s:HOST.'/res/noP.gif';
                        $path_s_str = '<img src="'.$path_s_url.'" class="m yuan">';
                        $ewmurl=urlencode(HOST.'/m/qun_detail.php?id='.$id);
						$Unum = $db->COUNT(__TBL_QUN_U__,"qid=".$id);
						$wznum = $db->COUNT(__TBL_TREND__,"kind=2 AND qid=".$id);
						$bbsnum = $db->COUNT(__TBL_TREND_BBS__,"kind=2 AND qid=".$id);
                    ?>
                    <tr id="tr<?php echo $id;?>">
                        <td width="20" height="40"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $senduid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
                        </td>
                      <td width="35" class="C999"><label for="id<?php echo $id; ?>"><?php echo $id;?></label></td>
                        <td width="30" align="center"><a href="<?php echo "qun.php?id=".$id; ?>&submitok=ding" class="topico" title="置顶"></a></td>
                        <td width="60" align="center"><a href="javascript:;" class="zoom" onClick="parent.piczoom('<?php echo smb($path_s_url,'b'); ?>');"><?php echo $path_s_str; ?></a></td>
                        <td width="170" align="left">
                        <a href="qun.php?submitok=mod&id=<?php echo $id;?>&p=<?php echo $p;?>" class="S14"><?php echo $title;?></a>
                        <?php
                        if(ifint($uid)){
							$rowU = $db->ROW(__TBL_USER__,"sex,grade,photo_s,nickname","id=".$uid,"name");
							if ($rowU){
								$Usex   = $rowU['sex'];
								$Ugrade = $rowU['grade'];
								$Uphoto_s  = $rowU['photo_s'];
								$Unickname = trimhtml(dataIO($rowU['nickname'],'out'));
								$title2 = (!empty($Unickname))?urlencode($Unickname).'／'.$uid:$uid;
							?><hr class="br">
                          <a href="javascript:;" class="photo_s C999"  uid="<?php echo $uid;?>" title2="<?php echo $title2;?>" title="浏览个人主页">群主UID：<?php echo $uid;?></a>
						<?php }}?>
                        </td>
                        <td width="50" align="center"><a href="javascript:;" onclick="parent.zeai.iframe('【<?php echo $title;?>】二维码','u_ewm.php?url=<?php echo $ewmurl;?>&ifshowurl=1',400,400);" title="放大二维码/复制链接网址" class="zoom">
                <img src="images/ewm.gif" class="ewmpic">
                </a></td>
                        <td align="center">&nbsp;</td>
                        <td width="45" align="center"><a class="<?php echo ($Unum >0)?'aHONG':'aHUI';?>" onClick="zeai.iframe('【<?php echo trimhtml($title);?>】参与用户','qun_detail_u.php?fid=<?php echo $id;?>',666,550)"><?php echo $Unum;?></a></td>
                        <td width="45" align="center"><a href="qun_trend.php?qid=<?php echo $qid;?>" class="<?php echo ($wznum >0)?'aHONG':'aHUI';?>"><?php echo $wznum;?></a></td>
                      <td width="45" align="center"><a href="qun_bbs.php?qid=<?php echo $qid;?>" class="<?php echo ($bbsnum >0)?'aHONG':'aHUI';?>"><?php echo $bbsnum;?></a></td>
                      <td width="22" align="center">&nbsp;</td>
                        <td width="170" align="left" class="C999">
                        <?php
                        $price = json_decode($price,true);
                        if (is_array($urole) && count($urole)>0){?>
                            <?php
                            foreach($urole as $RV){
								if($RV['f']==0)continue;
                                $grade = $RV['g'];
                                $p1 = $price['1_'.$grade];
                                $p2 = $price['2_'.$grade];
                                $p1_str=($p1>0)?'<font class="Cf00">￥'.floatval($p1).'</font>':'<font class="C090">免费</font>';
                                $p2_str=($p2>0)?'<font class="Cf00">￥'.floatval($p2).'</font>':'<font class="C090">免费</font>';?>
                                
                                <?php echo uicon_grade_all($grade,1,1); ?> <?php echo $p1_str;?>
                                <?php echo uicon_grade_all($grade,1,2); ?> <?php echo $p2_str;?><br>
                                <?php
                            }
                        }else{
                            echo "<div class='nodatatipsS'>暂无用户组<br><br><a class='btn size1' href='urole.php'>新增用户组</a></div>";
                        }
                        ?>
                        </td>
                  <td width="70" align="center" class="C999"><?php echo YmdHis($addtime);?></td>
                      <td width="60" align="center">
                            <?php if($flag==-1){?><a clsid="<?php echo $id;?>" class="aHEI flag">已锁定</a><?php }?>
                            <?php if($flag==1){?><a clsid="<?php echo $id;?>" class="aLV flag">正常</a><?php }?>
                            <?php if($flag==0){?><a clsid="<?php echo $id;?>" class="aHUANG flag">未审</a><?php }?>
                            <?php if($flag==2){?><a clsid="<?php echo $id;?>" class="aLAN flag">禁止加入</a><?php }?>
							<?php
							echo '<br><br>';
                            switch ($chatqx) {
                                case 0:echo '全体成员';break;
                                case 1:echo '只有群主';break;
                                case 2:echo '全体禁言';break;
                            }
                            ?>
                      </td>
                      <td width="60" align="center">
                      <a href="qun.php?submitok=mod&id=<?php echo $id;?>&p=<?php echo $p;?>" class="editbtn"></a>
                      <a class="delbtn" clsid="<?php echo $id;?>"></a>
                      </td>
                      <td width="15" align="center">&nbsp;</td>
                      </tr>
                    <?php } ?>
                </table>
                <?php if ($total > $pagesize){?>
                <div class="listbottombox" style="text-align:center">
                    <input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
                    <input type="hidden" name="submitok" id="submitok" value="" />
                    <?php echo '<div class="pagebox">'.$pagelist.'</div>'; ?>
                </div>
                <?php }?>
                </form>
                <script>
                var bg = '<?php echo $_Style['list_bg']; ?>',overbg = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
                zeai.listEach('.delbtn',function(obj){
                    obj.onclick = function(){
                        var id = parseInt(obj.getAttribute("clsid"));
                        zeai.confirm('<b class="S18">★请慎重★　确定真的要删除么？</b><br>删除后将同步删除对应的用户报名数据等',function(){
                            zeai.ajax({url:'qun'+zeai.ajxext+'submitok=ajax_del&id='+id},function(e){var rs=zeai.jsoneval(e);
                                zeai.msg(0);zeai.msg(rs.msg);
                                if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
                            });
                        });
                    }
                });
                zeai.listEach('.flag',function(obj){
                    obj.onclick = function(){
                        var id = parseInt(obj.getAttribute("clsid"));
                        zeai.ajax({url:'qun'+zeai.ajxext+'submitok=ajax_flag&id='+id},function(e){var rs=zeai.jsoneval(e);
                            zeai.msg(0);zeai.msg(rs.msg);
                            if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
                        });
                    }
                });
                </script>
                <script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
            <?php }?>
        <?php }?>
	</div>
    <div class="clear"></div>
</div>
<?php if ($submitok == 'add' || $submitok == 'mod'){?>
	<div class="savebtnbox"><button type="button" class="btn size3" id="save">保存并发布</button></div>
	<script>
    <?php if($submitok=='mod'){?>
    window.onload=function(){
        path_s_mod();
        function path_s_mod(){
            var i=zeai.tag(picli_path,'i')[0],img=zeai.tag(picli_path,'img')[0];
            if(zeai.empty(i))return;
            path_add.hide();
            var src=img.src.replace(up2,'');
            path_s.value=src;
            i.onclick = function(){zeai.confirm('亲~~确认删除么？',function(){img.parentNode.remove();path_add.show();path_s.value='';});}
            img.onclick = function(){parent.piczoom(up2+src.replace('_s.','_b.'));}
        }
        bn_s_mod();
        function bn_s_mod(){
            var i=zeai.tag(picli_path2,'i')[0],img=zeai.tag(picli_path2,'img')[0];
            if(zeai.empty(i))return;
            path_add2.hide();
            var src=img.src.replace(up2,'');
            bn_s.value=src;
            i.onclick = function(){zeai.confirm('亲~~确认删除么？',function(){img.parentNode.remove();path_add2.show();bn_s.value='';});}
            img.onclick = function(){parent.piczoom(up2+src.replace('_s.','_b.'));}
        }
    }
    <?php }?>
    zeai.photoUp({
        btnobj:path_add,
        upMaxMB:upMaxMB,
        url:"qun"+zeai.extname,
        submitok:"ajax_pic_path_s_up",
        end:function(rs){
            //zeai.msg(0);zeai.msg(rs.msg);
            if (rs.flag == 1){
                picli_path.append('<li><img src="'+up2+rs.dbname+'"><i></i></li>');
                path_s.value=rs.dbname;
                path_add.hide();
                var i=zeai.tag(o(picli_path),'i')[0],img=zeai.tag(o(picli_path),'img')[0];
                i.onclick = function(){zeai.confirm('亲~~确认删除么？',function(){img.parentNode.remove();path_add.show();path_s.value='';});}
                img.onclick = function(){parent.piczoom(up2+rs.dbname.replace('_s.','_b.'));}
            }
        }
    });
    zeai.photoUp({
        btnobj:path_add2,
        upMaxMB:upMaxMB,
        url:"qun"+zeai.extname,
        submitok:"ajax_pic_bn_s_up",
        end:function(rs){
            //zeai.msg(0);zeai.msg(rs.msg);
            if (rs.flag == 1){
                picli_path2.append('<li><img src="'+up2+rs.dbname+'"><i></i></li>');
                bn_s.value=rs.dbname;
                path_add2.hide();
                var i=zeai.tag(o(picli_path2),'i')[0],img=zeai.tag(o(picli_path2),'img')[0];
                i.onclick = function(){zeai.confirm('亲~~确认删除么？',function(){img.parentNode.remove();path_add2.show();bn_s.value='';});}
                img.onclick = function(){parent.piczoom(up2+rs.dbname.replace('_s.','_b.'));}
            }
        }
    });
    function drag_init3(){(function (){[].forEach.call(stepbox3.getElementsByClassName('stepli3'), function (el){Sortable.create(el,{group: 'zeai_reg3',animation:150});});})();}drag_init3();
    save.onclick = function(){
		var DATAPX=[];
		zeai.listEach('.bmtj_li',function(obj){DATAPX.push(obj.value);});
		tj_before_px.value=DATAPX.join(",");
		zeai.ajax({url:'qun'+zeai.extname,form:ZEAI_FORM},function(e){var rs=zeai.jsoneval(e);
			zeai.msg(rs.msg);if(rs.flag==1)setTimeout(function(){zeai.openurl('qun'+zeai.ajxext+'p=<?php echo $p;?>');},1000);
		});
    }
    </script>
<?php }?>
<script src="laydate/laydate.js"></script>
<script>
laydate.render({
	theme: 'molv'
	,elem: '#jzbmtime'
	,type: 'datetime'
}); 
laydate.render({
	theme: 'molv'
	,elem: '#hxtime'
	,type: 'datetime'
}); 
zeai.listEach('.photo_s',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid"));
		var title2 = obj.getAttribute("title2");
		var photo_s_url = decodeURIComponent(obj.getAttribute("photo_s_url"));
		crm_homepage({uid:uid,title2:title2,photo_s_url:photo_s_url});
	}
});
</script>
<?php
function chatContact_data_title($var) {
	switch ($var){
		case 'rz_mob':$t = '完成手机认证';break;
		case 'rz_identity':$t = '完成实名认证';break;
		case 'rz_photo':$t = '完成真人认证';break;
		case 'bfb':$t = '资料完整度达';break;
		case 'photo':$t = '有头像且已审';break;
		case 'sex':$t = '对方必须异性';break;
		case 'mysex1':$t = '报名者为男性';break;
		case 'mysex2':$t = '报名者为女性';break;
		case 'vip':$t = 'VIP用户';break;
	}
	return $t;
}
require_once 'bottomadm.php';?>